package com.leetcode.array_matrix;

/**
 * @author Dennis Li
 * @date 2020/7/18 23:01
 */
public class MoveZeroes_283 {

    public void moveZeroes(int[] nums) {
        int zero = 0;
        for (int i = 0; i < nums.length; i++) {
            if (nums[i] == 0) zero++;
            else swap(nums, i, i - zero);
        }
    }

    public void swap(int[] nums, int x, int y) {
        int temp = nums[x];
        nums[x] = nums[y];
        nums[y] = temp;
    }

}
